ImageGear Professional DLL for Windows
Exporting to a PDF Output Document

The ImageGear Recognition API allows saving recognized data to PDF documents. Unlike exporting to other output formats that use the Recognition API, exporting recognition results to a PDF is accomplished by using ImageGear Multipage Document functions. You only need to export the recognized page to PDF page and append this page to an ImageGear multi-page document.

This PDF export feature requires a license that enables the PDF format.

IG_REC_PDF_page_create function will create a new PDF page and add the recognized text, and optionally the original input image, to it. The original image can be segmented and automatically compressed differently based upon the recognized zones. The new page is then appended to the new or existing PDF document specified in the second parameter.

Alternatively, if a PDF page already exists, the IG_REC_PDF_page_populate function can populate the page with the recognized data and/or original input image. Any existing content of the PDF page is preserved.

Once the recognized data has been added to the PDF document by either of the above functions, the IG_mpi_file_save function can be called to write the PDF document to a file.

Both the IG_REC_PDF_page_create and IG_REC_PDF_page_populate functions take AT_REC_PDF_PAGE_OPTIONS parameter to adjust settings of the output PDF document. These settings allow the caller to show or hide the added text and/or image, specify the PDF fonts to use for various types of text, and select whether to add text to the PDF using Windows ANSI or Unicode encoding.

Saving the Recognized Data Directly in PDF Format

C
Copy Code
AT_ERRCOUNT nErrCount;
HIG_REC_IMAGE hImg;
HIGEAR hIGear;
HMIGEAR hMPDoc;
AT_REC_PDF_PAGE_OPTIONS opt;
nErrCount = IG_load_file("Image.tif", &hIGear );
nErrCount = IG_REC_image_import(hIGear, &hImg);
nErrCount = IG_image_delete(hIGear);
nErrCount = IG_REC_image_preprocess(hImg);
nErrCount = IG_REC_image_recognize(hImg);
// Create an empty PDF document
nErrCount = IG_mpi_create(&hMPDoc, 0);
nErrCount = IG_PDF_doc_create(hMPDoc);
// Set options for IG_REC_PDF_page_create to add an
// image to the page, and segment the image based on
// the recognized zones.
memset(&opt, 0, sizeof(opt));
opt.VisibleImage = TRUE;
opt.VisibleText = FALSE;
opt.SegmentImage = TRUE;
// Create PDF page with recognized text
nErrCount = IG_REC_PDF_page_create(hImg, hMPDoc, &opt);
// Save PDF document
nErrCount = IG_mpi_file_save("ONEPAGE.pdf", hMPDoc, 0, 0, 1, IG_FORMAT_PDF, IG_MPI_SAVE_OVERWRITE);
// Delete the document
nErrCount = IG_mpi_delete(hMPDoc);
// Delete the recognition image
nErrCount = IG_REC_image_delete(hImg);

 

 


©2014. Accusoft Corporation. All Rights Reserved.

Send Feedback